<html>
<head><meta charset="utf-8"><title>Resolve impl for trait method · t-compiler/help · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/index.html">t-compiler/help</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Resolve.20impl.20for.20trait.20method.html">Resolve impl for trait method</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="221561671"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Resolve%20impl%20for%20trait%20method/near/221561671" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> rylev <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Resolve.20impl.20for.20trait.20method.html#221561671">(Jan 04 2021 at 18:30)</a>:</h4>
<p>If I have a DefId for a method expression, can I get a DefId that identifies the method implementation? I need to check if the method invocation will monomorphize to a particular implementation. I’ve not worked with monomorphization before so perhaps I’m thinking about things all wrong.</p>



<a name="221564686"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Resolve%20impl%20for%20trait%20method/near/221564686" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Resolve.20impl.20for.20trait.20method.html#221564686">(Jan 04 2021 at 18:55)</a>:</h4>
<p><a href="https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/struct.Instance.html#method.resolve"><code>Instance::resolve</code></a> is what I'd try.</p>



<a name="221564915"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Resolve%20impl%20for%20trait%20method/near/221564915" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Resolve.20impl.20for.20trait.20method.html#221564915">(Jan 04 2021 at 18:57)</a>:</h4>
<p>(<code>Instance::resolve</code> is what monomorphization collection invokes when it walks the call graph from non-generic roots and has all substitutions available)</p>



<a name="221565007"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Resolve%20impl%20for%20trait%20method/near/221565007" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Resolve.20impl.20for.20trait.20method.html#221565007">(Jan 04 2021 at 18:57)</a>:</h4>
<p>Depending where you are in the compiler and what information you've got available, it might work for you <span aria-label="smile" class="emoji emoji-1f642" role="img" title="smile">:smile:</span></p>



<a name="221565150"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Resolve%20impl%20for%20trait%20method/near/221565150" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> rylev <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Resolve.20impl.20for.20trait.20method.html#221565150">(Jan 04 2021 at 18:58)</a>:</h4>
<p>Ok I tried that earlier and got an ICE, but I’ll try again 😅</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>